This resource address creates a new trigger.
URL Parameters | |
---|---|
format | The format of the data in the request body. Allowed
values: html , json or xml (default). Use this
parameter to override the Accept header. |
Upon success, MarkLogic Server returns status code 200 (OK). If the trigger already exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.
manage-admin
rolehttp://marklogic.com/xdmp/privileges/manage-admin
http://marklogic.com/xdmp/privileges/manage
http://marklogic.com/xdmp/privileges/create-trigger
and
http://marklogic.com/xdmp/privileges/manage
privilege, plus one of the following privileges:
http://marklogic.com/xdmp/privileges/admin/database
http://marklogic.com/xdmp/privileges/admin/database/database-ID
http://marklogic.com/xdmp/privileges/admin/database/triggers/database-ID
http://marklogic.com/xdmp/privileges/admin/database/database-name
http://marklogic.com/xdmp/privileges/admin/database/triggers/database-name
The structure of the data in a create trigger request is as shown below.
id
name
description
event
This is a complex structure with the following children:
data-event
This is a complex structure with the following children:
document-scope
This is a complex structure with the following children:
uri
collection-scope
This is a complex structure with the following children:
uri
directory-scope
This is a complex structure with the following children:
uri
depth
document-content
This is a complex structure with the following children:
update-kind
any-property-content
any-custom-property-content
property-content
This is a complex structure with the following children:
property-name
This is a complex structure with the following children:
namespace-uri
localname
when
database-online-event
This is a complex structure with the following children:
user
user-id
user-name
module
module-db
module-root
enabled
recursive
task-priority
permissions
This is a complex structure with the following children:
permission
This is a complex structure with the following children:
role-name
capability
curl -X POST --anyauth --user admin:admin --header "Content-Type:application/json" \ -d '{ "name": "my-trigger", "description": "my trigger", "event": { "data-event": { "directory-scope": { "uri": "/myDir/", "depth": "1" }, "document-content": { "update-kind": "create" }, "when": "post-commit" } }, "module": "/test.xqy", "module-db": "Modules", "module-root": "/modules/", "enabled": true, "recursive": true, "task-priority": "normal" }' \ http://localhost:8002/manage/v2/databases/myTriggers/triggers ==> Creates a new trigger, named "my-trigger," for the myTriggers database.